package com.xjoyt.pay.master.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xjoyt.pay.controllers.AbstractController;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.dto.PageParam;
import com.xjoyt.pay.dto.PageResult;
import com.xjoyt.pay.master.interfaces.DistributorContract;
import com.xjoyt.pay.master.po.Distributor;
import com.xjoyt.pay.master.services.DistributorService;
import com.xjoyt.pay.merchant.register.params.DistributorPageParam;
import com.xjoyt.pay.params.ChangePasswordParam;
import com.xjoyt.pay.params.LoginParam;

@RestController
@RequestMapping("distributor")
public class DistributorController extends AbstractController implements DistributorContract {

	@Autowired
	private DistributorService service;

	@Override
	public Distributor get(@PathVariable("id") String id) {
		return service.get(id);
	}

	@Override
	public PageResult<Distributor> loadPage(@RequestBody PageParam<DistributorPageParam> param) {
		return service.loadPage(param);
	}

	@Override
	public ExecuteResult<?> changePassword(@RequestBody ChangePasswordParam param) {
		return service.changePassword(param);
	}

	@Override
	public ExecuteResult<?> create(@RequestBody com.xjoyt.pay.merchant.register.po.Distributor param) {
		return service.create(param);
	}

	@Override
	public Distributor getByNo(@PathVariable("no") String no) {
		return service.getByNo(no);
	}

	@Override
	public ExecuteResult<String> resetKey(@PathVariable("id") String id) {
		return service.resetKey(id);
	}

	@Override
	public ExecuteResult<Distributor> getForLogin(@RequestBody LoginParam param) {
		return service.getForLogin(param.account, param.password);
	}

	@Override
	public ExecuteResult<Distributor> update(@RequestBody Distributor param) {
		return service.update(param);
	}

}
